package com.demo;

import java.util.HashMap;

/**
 * <p>
 * <code>ExceptionTest</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-06-05 15:08
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
public class ExceptionTest {
    public static void main(String[] args) {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("1","1");
        hashMap.put("2","2");

        for (String key : hashMap.keySet()) {
            //key.equals("1") 没关系
            //key.equals("2") 报错：ConcurrentModificationException
            if (key.equals("2")){
                hashMap.remove(key);
            }
        }

    }
}
